<template>
    <div class="module">
        <!--<el-tabs v-model="activeName" @tab-click="handleClick" stretch class="tab_check_bill">-->
            <!--<el-tab-pane name="confirming">-->
                <!--<span slot="label">待确认<MarkRemind :tipsNum="this.orderTips.proOrderCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--<el-tab-pane name="handling">-->
                <!--<span slot="label">待处理订单<MarkRemind :tipsNum="this.orderTips.orderNotOverDueCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--<el-tab-pane name="expired">-->
                <!--<span slot="label">逾期处理<MarkRemind :tipsNum="this.orderTips.orderOverDueCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
        <!--</el-tabs>-->
        <el-menu :default-active="activeName" mode="horizontal" class="tab_menu_check_bill">
            <el-menu-item index="confirming" @click="handleClick('confirming')">待确认<MarkRemind :tipsNum="this.orderTips.proOrderCount"></MarkRemind></el-menu-item>
            <el-menu-item index="handling" @click="handleClick('handling')">待处理订单<MarkRemind :tipsNum="this.orderTips.orderNotOverDueCount"></MarkRemind></el-menu-item>
            <el-menu-item index="expired" @click="handleClick('expired')">逾期处理<MarkRemind :tipsNum="this.orderTips.orderOverDueCount"></MarkRemind></el-menu-item>
        </el-menu>

        <el-row>
            <el-col :span="24" class="check_bill_int">
                <el-input placeholder="企业名称/联系方式/订单号/票据号" v-model="filterModel.searchBoxValue" clearable @clear="chooseFind()"></el-input>
                <el-button type="primary" size="small" @click="chooseFind()">搜索</el-button>
            </el-col>
            <el-col :span="24">
                <FiltrateTemplate
                        :templateSource="this.filterSource"
                        :templateState="this.activeName"
                        @changeOrderRoleFun="changeOrderRoleFun"
                        @changeOrderSourceFun="changeOrderSourceFun"
                        @clearAllChooseFun="clearAllChooseFun"
                        @closeTagFun="closeTagFun"
                        ref="orderFilter">
                </FiltrateTemplate>
            </el-col>
        </el-row>
        <!--<el-tabs v-if="activeName == 'confirming'" v-model="activeConfirm" @tab-click="handleClick2" stretch class="tab_check_bill">-->
            <!--<el-tab-pane label="全部" name="all"></el-tab-pane>-->
            <!--<el-tab-pane name="normalConfirm">-->
                <!--<span slot="label">正常待确认<MarkRemind :tipsNum="this.orderTips.proOrderNotOverDueCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--<el-tab-pane name="overdueConfirm">-->
                <!--<span slot="label">逾期待确认<MarkRemind :tipsNum="this.orderTips.proOrderOverDueCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
        <!--</el-tabs>-->
        <el-menu v-if="activeName == 'confirming'" :default-active="activeConfirm" mode="horizontal" class="tab_menu_check_bill">
            <el-menu-item index="all" @click="handleClick2('all')">全部</el-menu-item>
            <el-menu-item index="normalConfirm" @click="handleClick2('normalConfirm')">正常待确认<MarkRemind :tipsNum="this.orderTips.proOrderNotOverDueCount"></MarkRemind></el-menu-item>
            <el-menu-item index="overdueConfirm" @click="handleClick2('overdueConfirm')">逾期待确认<MarkRemind :tipsNum="this.orderTips.proOrderOverDueCount"></MarkRemind></el-menu-item>
        </el-menu>

        <el-menu v-if="activeName != 'confirming' && filterOrderModel.orderSource != '305'" :default-active="activeStatus" mode="horizontal" class="tab_menu_check_bill">
            <el-menu-item index="all" @click="handleClick3('all')">全部</el-menu-item>
            <el-menu-item index="804" @click="handleClick3('804')" v-if="this.filterOrderModel.orderRole == '0' || this.filterOrderModel.orderRole == ''">待支付
                <MarkRemind :tipsNum="this.orderTips.orderNotOverDueToPayCount" v-if="activeName == 'handling'"></MarkRemind>
                <MarkRemind :tipsNum="this.orderTips.orderOverDueCountToPayCount" v-if="activeName == 'expired'"></MarkRemind>
            </el-menu-item>
            <el-menu-item index="806" @click="handleClick3('806')" v-if="filterOrderModel.orderRole == '1' || filterOrderModel.orderRole == ''">待背书
                <MarkRemind :tipsNum="this.orderTips.orderNotOverDueToEndorseCount" v-if="activeName == 'handling'"></MarkRemind>
                <MarkRemind :tipsNum="this.orderTips.orderOverDueCountToEndorseCount" v-if="activeName == 'expired'"></MarkRemind>
            </el-menu-item>
            <el-menu-item index="807" @click="handleClick3('807')" v-if="filterOrderModel.orderRole == '0' || filterOrderModel.orderRole == ''">待签收
                <MarkRemind :tipsNum="this.orderTips.orderNotOverDueToSignCount" v-if="activeName == 'handling'"></MarkRemind>
                <MarkRemind :tipsNum="this.orderTips.orderOverDueCountToSignCount" v-if="activeName == 'expired'"></MarkRemind>
            </el-menu-item>
            <el-menu-item index="808" @click="handleClick3('808')" v-if="filterOrderModel.orderRole == '1' || filterOrderModel.orderRole == ''">待放款</el-menu-item>
            <el-menu-item index="810" @click="handleClick3('810')">交易完成</el-menu-item>
            <el-menu-item index="816" @click="handleClick3('816')">交易中止</el-menu-item>
        </el-menu>

        <el-menu v-if="activeName != 'confirming' && (filterOrderModel.orderSource == 305 || filterOrderModel.orderSource == '305')" :default-active="activeFStatus" mode="horizontal" class="tab_menu_check_bill">
            <el-menu-item index="all" @click="handleClick4('all')">全部</el-menu-item>
            <el-menu-item index="1" @click="handleClick4('1')">待提票</el-menu-item>
            <el-menu-item index="6" @click="handleClick4('6')">交易成功</el-menu-item>
            <el-menu-item index="8" @click="handleClick4('8')">交易失败</el-menu-item>
        </el-menu>


        <!--<el-tabs v-if="activeName != 'confirming' && filterOrderModel.orderSource != '305'" v-model="activeStatus" @tab-click="handleClick3" stretch class="tab_check_bill">-->
            <!--<el-tab-pane label="全部" name="all"></el-tab-pane>-->
            <!--<el-tab-pane name="804" v-if="this.filterOrderModel.orderRole == '0' || this.filterOrderModel.orderRole == ''">-->
                <!--<span slot="label" v-if="activeName == 'handling'">待支付<MarkRemind :tipsNum="this.orderTips.orderNotOverDueToPayCount" class="bid_tips"></MarkRemind></span>-->
                <!--<span slot="label" v-if="activeName == 'expired'">待支付<MarkRemind :tipsNum="this.orderTips.orderOverDueCountToPayCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--<el-tab-pane name="806" v-if="filterOrderModel.orderRole == '1' || filterOrderModel.orderRole == ''">-->
                <!--<span slot="label" v-if="activeName == 'handling'">待背书<MarkRemind :tipsNum="this.orderTips.orderNotOverDueToEndorseCount" class="bid_tips"></MarkRemind></span>-->
                <!--<span slot="label" v-if="activeName == 'expired'">待背书<MarkRemind :tipsNum="this.orderTips.orderOverDueCountToEndorseCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--&lt;!&ndash;<el-tab-pane name="806" v-if="filterOrderModel.orderRole == ''">&ndash;&gt;-->
                <!--&lt;!&ndash;<span slot="label" v-if="activeName == 'handling'">待背书<MarkRemind :tipsNum="this.orderTips.orderNotOverDueToEndorseCount" class="bid_tips"></MarkRemind></span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span slot="label" v-if="activeName == 'expired'">待背书<MarkRemind :tipsNum="this.orderTips.orderOverDueCountToEndorseCount" class="bid_tips"></MarkRemind></span>&ndash;&gt;-->
            <!--&lt;!&ndash;</el-tab-pane>&ndash;&gt;-->
            <!--<el-tab-pane name="807" v-if="filterOrderModel.orderRole == '0' || filterOrderModel.orderRole == ''">-->
                <!--<span slot="label" v-if="activeName == 'handling'">待签收<MarkRemind :tipsNum="this.orderTips.orderNotOverDueToSignCount" class="bid_tips"></MarkRemind></span>-->
                <!--<span slot="label" v-if="activeName == 'expired'">待签收<MarkRemind :tipsNum="this.orderTips.orderOverDueCountToSignCount" class="bid_tips"></MarkRemind></span>-->
            <!--</el-tab-pane>-->
            <!--<el-tab-pane label="待放款" name="808" v-if="filterOrderModel.orderRole == '1' || filterOrderModel.orderRole == ''"></el-tab-pane>-->
            <!--<el-tab-pane label="交易完成" name="810"></el-tab-pane>-->
            <!--<el-tab-pane label="交易中止" name="816"></el-tab-pane>-->
        <!--</el-tabs>-->
        <!--<el-tabs v-if="activeName != 'confirming' && (filterOrderModel.orderSource == 305 || filterOrderModel.orderSource == '305')" v-model="activeFStatus" @tab-click="handleClick4" stretch class="tab_check_bill">-->
            <!--<el-tab-pane label="全部" name="all"></el-tab-pane>-->
            <!--<el-tab-pane label="待提票" name="1"></el-tab-pane>-->
            <!--<el-tab-pane label="交易成功" name="6"></el-tab-pane>-->
            <!--<el-tab-pane label="交易失败" name="8"></el-tab-pane>-->
        <!--</el-tabs>-->



        <el-table :data="tableData" stripe style="width: 100%" :key="tableData.id"
                  class="order_table_box btn_margin_style"
                  @sort-change='sortChangeOrder'
        >
            <el-table-column v-if="this.activeName == 'confirming'" label="发布时间">
                <template slot-scope="scope">
                    <span>{{scope.row.crTime_Y}}</span><br/><span>{{scope.row.crTime_H}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="orderNumber" v-if="this.activeName != 'confirming'" label="订单号"> </el-table-column>
            <el-table-column v-if="this.activeName != 'confirming'" label="创建时间">
                <template slot-scope="scope">
                    <span>{{scope.row.crTime_Y}}</span><br/><span>{{scope.row.crTime_H}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="orderSourceName" label="订单来源"> </el-table-column>
            <el-table-column prop="drawerName" label="出票企业"> </el-table-column>
            <el-table-column prop="acceptorName" label="承兑人"> </el-table-column>
            <el-table-column prop="billSumPrice" label="票面金额(万元)" sortable width="143"> </el-table-column>
            <el-table-column label="到期时间" sortable>
                <template slot-scope="scope">
                    <span>{{scope.row.deadlineTime}}</span><br/><span v-if="scope.row.days > 0">(剩余{{scope.row.days}}天)</span>
                </template>
            </el-table-column>
            <el-table-column label="每十万扣款">
                <template slot-scope="scope">
                    <span class="tableRed" v-if="scope.row.everyPlus != '' && scope.row.everyPlus != undefined && scope.row.everyPlus != null">{{scope.row.biddingModeName}}{{scope.row.everyPlus}}元</span>
                    <span class="tableRed" v-if="scope.row.everyPlus == '' || scope.row.everyPlus == undefined || scope.row.everyPlus == null">竞价</span>
                </template>
            </el-table-column>
            <el-table-column prop="bankName" label="电票所在户"> </el-table-column>
            <el-table-column prop="billNumberShort" label="票据后六位"> </el-table-column>
            <el-table-column prop="" label="状态" class="bid_status_box">
                <template slot-scope="scope">
                    <div>
                        <div
                            @mouseenter="enterStatus(scope.row)"
                            @mouseleave="leaveStatus(scope.row)"
                            >{{scope.row.ordreStatusName}}</div>
                        <div class="bid_list_box" v-if="scope.row.isShowBid && scope.row.bidList != null">
                            <div class="bid_list_title">
                                机构报价
                            </div>
                            <el-table :data="scope.row.bidList" stripe class="bid_table">
                                <el-table-column prop="every_plus" label="每十万扣(元)"> </el-table-column>
                                <el-table-column prop="bid_time" label="报价时间"> </el-table-column>
                                <el-table-column prop="bid_enterprise_name" label="报价机构"> </el-table-column>
                            </el-table>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="waitedTimeStr" label="等待时间"> </el-table-column>
            <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="removeOffer(scope.row)" v-if="scope.row.orderStatusId == 0"><i class="iconfont icon-chexiao icon_edit_style"></i> 撤销</el-button>
                    <el-button type="text" size="small" @click="editBill(scope.row)" v-if="scope.row.orderStatusId == 0 && scope.row.waitedTime < 0"><i class="iconfont icon-xiugai icon_edit_style"></i> 修改</el-button>
                    <el-button type="text" size="small" @click="openEvaluate(scope.row)" v-if="scope.row.orderStatusId > 810 && scope.row.orderStatusId < 814" class="check_btn_style">评价</el-button>
                    <el-button type="text" size="small" @click="onRecharge(scope.row)" v-if="scope.row.orderStatusId >= 804 && scope.row.orderStatusId <= 814"><i class="iconfont icon-zhongzhi icon_edit_style"></i> 中止</el-button>
                    <el-button type="text" size="small" @click="openDetail(scope.row)"><i class="iconfont icon-xiangqing icon_edit_style"></i> 详细</el-button>
                    <el-button size="small" @click="syncOrder(scope.row)" v-if="scope.row.orderStatusId == 805 || scope.row.orderStatusId == 808 || scope.row.orderStatusId == 809 || scope.row.orderStatusId == 814" class="check_btn_style">同步</el-button>
                    <el-button size="small" @click="signInfor(scope.row)" v-if="scope.row.orderStatusId == 807" class="check_btn_style">签收</el-button>
                    <el-button size="small" @click="sendAgain(scope.row)" v-if="scope.row.orderStatusId == 808" class="check_btn_style">重发</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="right clear">
            <el-pagination
                    @size-change="onSizeChange"
                    @current-change="onFlipOver"
                    :current-page="pagination.currentPage"
                    :page-sizes="pagination.pageSizes"
                    :page-size="pagination.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pagination.total">
            </el-pagination>
        </div>
        <EditBill
                ref="billEditDialog"
                :form="this.billForm"
                @formCheck="confirmSave"
                @closeDialog="closeDialog"
                :isCheckSave="this.isCheckSave"
        ></EditBill>
        <DialogContent ref="billDetailDialog" title="票据详情">
            <BillDetail :billModel="this.billModel" @closeDialog="closeDialog"></BillDetail>
        </DialogContent>
        <DialogContent ref="orderDetailDialog" title="订单详情">
            <OrderDetail :orderDetailModel="this.orderDetailModel" :orderStep="this.orderStep" :orderTime="this.orderTime"></OrderDetail>
            <span slot="Remfooter" class="submit-btn">
                <el-button type="info" size="small" @click="closeDialog()">关闭</el-button>
            </span>
        </DialogContent>
        <DialogContent ref="terminateOrder" title="中止订单">
            <div class="rem-dialog-con">
                <el-form ref="form" :model="form" label-width="100px">
                    <el-form-item label="中止原因：" class="terminate_reason">
                        <el-input type="textarea" v-model="form.description"></el-input>
                    </el-form-item>
                    <el-form-item label="中止方：" class="text_left">
                        <el-select v-model="form.terminate" placeholder="请选择">
                            <el-option
                                    v-for="item in dutyList"
                                    :key="item.duty"
                                    :label="item.dutyName"
                                    :value="item.duty">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="Remfooter" class="submit-btn">
                <el-button type="info" size="small" @click="closeDialog()">取消</el-button>
                <el-button type="primary" size="small" @click="comfirmStop()">确定</el-button>
            </span>
        </DialogContent>
        <DialogContent ref="evaluateDetail" title="评价详情">
            <div class="rem-dialog-con text_left">
                <el-row>
                    <el-col :span="24" class="form-title">
                        <div class="form-title-con">
                            出票方评价
                            <span class="evaluate_title">出票方企业名称：{{this.evaluateModel.drawerName}}</span>
                        </div>
                    </el-col>
                    <div v-if="evaluateModel.order_status_id == 811 || evaluateModel.order_status_id == 813">
                        <GiveMark :score="Number(evaluateModel.drawerStarLevel)" :isDisabled="true"/>
                        <el-col :span="24" class="row_text hpx-label evaluate_con_div" @changeScore="changeScore">评价内容</el-col>
                        <el-col :span="24" class="evaluate_con_div evaluate_con_main">{{this.evaluateModel.drawerDescription}}</el-col>
                    </div>
                    <div v-if="evaluateModel.order_status_id != 811 && evaluateModel.order_status_id != 813">
                        <span class="evaluate_con_left">出票方暂未给出评价！</span>
                    </div>
                    <el-col :span="24" class="form-title">
                        <div class="form-title-con">
                            收票方评价
                            <span class="evaluate_title">出票方企业名称：{{this.evaluateModel.receiverName}}</span>
                        </div>
                    </el-col>
                    <div v-if="evaluateModel.order_status_id == 812 || evaluateModel.order_status_id == 813">
                        <GiveMark :score="Number(evaluateModel.receiverStarLevel)" :isDisabled="true"/>
                        <el-col :span="24" class="row_text hpx-label evaluate_con_div" @changeScore="changeScore">评价内容</el-col>
                        <el-col :span="24" class="evaluate_con_div evaluate_con_main">{{this.evaluateModel.receiverDescription}}</el-col>
                    </div>
                    <div v-if="evaluateModel.order_status_id != 812 && evaluateModel.order_status_id != 813">
                        <span class="evaluate_con_left">收票方暂未给出评价！</span>
                    </div>
                </el-row>
            </div>
            <span slot="Remfooter" class="submit-btn">
                <el-button size="small" type="primary" class="dialog-button" @click="closeDialog()">关闭</el-button>
            </span>
        </DialogContent>
    </div>
</template>

<script lang="ts">
    import { Vue, Component } from 'vue-property-decorator';
    import { roleType, orderSourceTypes, dutyTypes } from '@/util/constantStatus';
    import DialogContent from '@common/DialogContent.vue';
    import BillDetail from '@common/BillDetail.vue';
    import EditBill from '@common/EditBill.vue';
    import OrderDetail from '@common/OrderDetail.vue';
    import Pagination from "@/types/Pagination";
    import GiveMark from '@common/GiveMark.vue';
    import _ from 'lodash';
    import moment from 'moment';
    import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
    import MarkRemind from '@component/common/MarkRemind.vue';
    import FiltrateTemplate from '@common/FiltrateTemplate.vue';

    @Component({
        components: {
            DialogContent,
            GiveMark,
            BillDetail,
            OrderDetail,
            EditBill,
            MarkRemind,
            FiltrateTemplate
        },
        extends: Pagination,
        computed: {
            ...mapState([
                'allTips',
                'orderTips',
                'tipState'
            ])
        },
        methods: {
            ...mapActions([
                'getAllTips',
                'getOrderTips'
            ]),
            ...mapMutations([
                'setTipState'
            ])
        }
    })
    export default class OrderCheck extends Vue {
        filterSource: string = 'orderManage';
        activeName = 'confirming'
        activeConfirm = 'all'
        activeStatus = 'all'
        activeFStatus = 'all'
        tableData = []
        orderModel:any = {};
        orderDetailModel: any = {};
        evaluateModel: any = {};
        orderTime: any = {
           order_status_804: '',
           order_status_806: '',
           order_status_807: '',
           order_status_808: '',
        };
        orderStep: any = 0;
        isCheckSave: string = '';
        form = {
            description: '',
            terminate: ''
        }
        billForm = {
            bill_flaw_ids: [1500],
            flaw_append: '',
            accept_type_ids: 401,
            bidding_mode: 3212,
            trade_appoint_day: 0
        }
        billModel: any = {};
        bidList: Array = []
        isClickDetail: boolean = false;
        orderByName: string = '';
        orderBySort: string = '';
        filterModel = {
            status: '801',
            isOverDue: '',
            fbankStatus: '',
            searchBoxValue: ''
        }
        filterOrderModel = {
            orderSource: '',
            orderRole: ''
        }
        roleOptions = roleType;
        orderSourceOptions = orderSourceTypes;
        // 取消订单一方
        dutyList = dutyTypes;

        filterFunction (filterForm: any) {
            this.pagination.currentPage = 1
            this.filterOrderModel = filterForm.filterModel;
            this.filterModel.status = this.filterModel.status
            this.filterModel.isOverDue = this.filterModel.isOverDue
            this.filterModel.fbankStatus = this.filterModel.fbankStatus
            this.filterModel.searchBoxValue = this.filterModel.searchBoxValue
            this.getOrderTips()
            this.getOrderList();
        }
        // 改变角色
        changeOrderRoleFun (data) {
            this.filterFunction(data)
        }
        // 改变订单来源
        changeOrderSourceFun (data) {
            this.filterFunction(data)
        }
        clearAllChooseFun (data) {
            this.filterFunction(data)
        }
        closeTagFun (data) {
            this.filterFunction(data)
        }

        handleClick(activeName:string) {
            this.activeName = activeName;
            this.pagination.currentPage = 1
            this.filterOrderModel = {
                orderSource: '',
                orderRole: ''
            }
            this.saveLocalStorage()
            if(this.activeName == 'confirming'){
                this.filterModel.status = '801';
                this.filterModel.isOverDue = '';
                this.$refs.orderFilter.clearAllChoose();
            } else if(this.activeName == 'handling'){
                this.filterModel.status = '';
                this.filterModel.isOverDue = '1';
                this.getOrderList();
            }else if(this.activeName == 'expired'){
                this.filterModel.status = '';
                this.filterModel.isOverDue = '0';
                this.getOrderList();
            }
        }
        handleClick2 (activeConfirm: string) {
            this.activeConfirm = activeConfirm;
            this.pagination.currentPage = 1
            if(this.activeConfirm == 'all'){
                this.filterModel.isOverDue = '';
            }else if(this.activeConfirm == 'normalConfirm'){
                this.filterModel.isOverDue = '1';
            }else if(this.activeConfirm == 'overdueConfirm'){
                this.filterModel.isOverDue = '0';
            }
            this.getOrderList();
        }
        handleClick3 (activeStatus: string) {
            this.activeStatus = activeStatus;
            this.pagination.currentPage = 1
            if (this.activeStatus == 'all'){
                this.filterModel.status = '';
            } else {
                this.filterModel.status = this.activeStatus;
            }
            this.getOrderList();
        }
        handleClick4 (activeFStatus: string) {
            this.activeFStatus = activeFStatus;
            this.pagination.currentPage = 1
            if (this.activeFStatus == 'all'){
                this.filterModel.fbankStatus = '';
            } else {
                this.filterModel.fbankStatus = this.activeFStatus;
            }
            this.getOrderList();
        }
        saveLocalStorage () {
            let saveData = this.activeName
            localStorage.setItem('orderManageActive',saveData)
        }
        // 点击改变瑕疵
        changeCheckFlaw (item) {
            if(this.billForm.bill_flaw_ids[this.billForm.bill_flaw_ids.length - 1] == 1500){
                this.billForm.bill_flaw_ids = [1500]
            }else if(this.billForm.bill_flaw_ids[this.billForm.bill_flaw_ids.length - 1] == 2202){
                this.billForm.bill_flaw_ids = [2202]
            }else {
                if(this.billForm.bill_flaw_ids.includes(1500)){
                    this.billForm.bill_flaw_ids.splice(item.indexOf(1500),1)
                    this.billForm.bill_flaw_ids = item;
                }else if(this.billForm.bill_flaw_ids.includes(2202)){
                    this.billForm.bill_flaw_ids.splice(item.indexOf(2202),1)
                    this.billForm.bill_flaw_ids = item;
                }
            }
            if(this.billForm.bill_flaw_ids.indexOf(1501) == -1){
                this.billForm.flaw_append = '';
            }
        }
        changeCheckbox () {

        }
        sortChangeOrder (column) {
            switch (column.prop)
            {
                case 'billSumPrice':
                    this.orderByName = 'bill_sum_price'
                    break;
                case 'deadlineTime':
                    this.orderByName = 'deadline_time'
                    break;
            }
            if (column.order == 'ascending'){
                this.orderBySort = 'asc';
            }else {
                this.orderBySort = 'desc';
            }
            this.getOrderList();
        }
        // 获取订单列表
        async getOrderList () {
            let findForm = {
                isOverDue: this.filterModel.isOverDue,
                billStyleId: this.filterOrderModel.orderSource,
                role: this.filterOrderModel.orderRole,
                status: this.filterModel.status,
                fbankStatus: this.filterModel.fbankStatus,
                searchBoxValue: this.filterModel.searchBoxValue,
                currentPage: this.pagination.currentPage,
                pageSize: this.pagination.pageSize,
                orderByName: this.orderByName,
                orderBySort: this.orderBySort
            }
            let res = await this.$http.post('orders/order/list',findForm)
            if (res.status == 200){
                let { orders } = res.data;
                _.forEach(orders, (i) => {
                    i.isShowBid = false
                    i.crTime_Y = moment(i.crTime).format('YYYY-MM-DD')
                    i.crTime_H = moment(i.crTime).format('HH:mm:ss')
                })
                this.tableData = orders;
                this.pagination.total = res.data.page_info.items_number;
            }
        }

        chooseFind () {
            this.getOrderList()
        }
        // 移入状态
        enterStatus (item) {
            item.isShowBid = true;
        }
        leaveStatus (item) {
            item.isShowBid = false;
        }
        // 打开详情
        openDetail (row) {
            if (this.activeName == 'confirming'){
                this.bidList = row.bidList;
                // 待确认状态，调查询票据接口
                this.isClickDetail = true;
                this.getBillDetail(row.billId, this.isClickDetail);
            } else {
                // 已生成订单，调订单接口
                this.getOrderDetail(row.id);
            }
        }
        onRecharge (row) {
            this.orderModel = row;
            this.$refs['terminateOrder'].openDialog();
        }
        editBill (row) {
            this.isCheckSave = 'editBillBtn';
            this.isClickDetail = false;
            this.getBillDetail(row.billId, this.isClickDetail);
        }
        closeDialog () {
            this.$refs['billDetailDialog'].closeDialog();
            this.$refs['orderDetailDialog'].closeDialog();
            this.$refs['terminateOrder'].closeDialog();
            this.$refs['billEditDialog'].closeDialog();
            this.$refs['evaluateDetail'].closeDialog();
        }
        comfirmStop () {
            if(!this.form.description){
                this.$alert('请填写中止原因。','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
                return;
            }
            this.orderStop(this.orderModel.id);
        }
        async getBillDetail (billId:string|number, isClickDetail:boolean) {
            let res = await this.$http.get(`bills/billProduct/getBillDetails/${billId}`)
            if(res.status == 200){
                this.billForm = res.data;
                this.billModel = res.data;
                this.billForm.eleBillAccount = res.data.account_information.bank_name;
                this.billForm.bill_deadline_time = moment(this.billForm.bill_deadline_time).format('YYYY-MM-DD');
                this.billModel.bill_deadline_time = moment(this.billModel.bill_deadline_time).format('YYYY-MM-DD');
                if(isClickDetail){
                    this.$refs['billDetailDialog'].openDialog();
                }else {
                    this.$refs['billEditDialog'].openDialog();
                }
            }
        }
        async getOrderDetail (orderId: string|number) {
            let res = await this.$http.get(`orders/order/${orderId}`)
            if(res.status == 200){
                this.orderDetailModel = res.data;
                this.orderDetailModel.bill_deadline_time = moment(this.orderDetailModel.bill_deadline_time).format('YYYY-MM-DD');
                if (res.data.bill_back_files.length == 1){
                    this.orderDetailModel.bill_back_photo_path1 = res.data.bill_back_files[0].file_path;
                    this.orderDetailModel.bill_back_photo_path2 = '';
                }else if(res.data.bill_back_files.length == 2){
                    this.orderDetailModel.bill_back_photo_path1 = res.data.bill_back_files[0].file_path;
                    this.orderDetailModel.bill_back_photo_path2 = res.data.bill_back_files[1].file_path;
                }
                switch (res.data.order_time_map.time.length)
                {
                    case 1:
                        this.orderStep = 0;
                        this.orderTime.order_status_804 = res.data.order_time_map.time[0].TIME;
                        break;
                    case 2:
                        this.orderStep = 1;
                        this.orderTime.order_status_804 = res.data.order_time_map.time[0].TIME;
                        this.orderTime.order_status_806 = res.data.order_time_map.time[1].TIME;
                        break;
                    case 3:
                        this.orderStep = 2;
                        this.orderTime.order_status_804 = res.data.order_time_map.time[0].TIME;
                        this.orderTime.order_status_806 = res.data.order_time_map.time[1].TIME;
                        this.orderTime.order_status_807 = res.data.order_time_map.time[2].TIME;
                        break;
                    case 4:
                        this.orderStep = 3;
                        this.orderTime.order_status_804 = res.data.order_time_map.time[0].TIME;
                        this.orderTime.order_status_806 = res.data.order_time_map.time[1].TIME;
                        this.orderTime.order_status_807 = res.data.order_time_map.time[2].TIME;
                        this.orderTime.order_status_808 = res.data.order_time_map.time[3].TIME;
                        break;
                }
                this.$refs['orderDetailDialog'].openDialog();
            }
        }
        async orderStop (orderId: string|number) {
            let stopForm = this.form
            let res = await this.$http.put(`orders/orderStop/${orderId}`,stopForm)
            if (res.status == 200){
                this.$refs['terminateOrder'].closeDialog();
                this.getAllTips()
                this.getOrderTips()
                this.$alert('订单中止成功','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
        }
        // 撤销询价
        removeOffer (row) {
            this.$confirm('是否确认撤销该企业的此张正在询价中的票据？','提醒',{
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                customClass: 'custom-message-box',
                center: true
            }).then(() => {
                this.$http.put(`bills/billProduct/user/${row.billProductId}`)
                    .then((res) => {
                        if(res.status == 204){
                            this.getOrderList();
                            this.getAllTips();
                            this.getOrderTips()
                            this.$alert('询价撤销成功。','提示',{
                                confirmButtonText: '确定',
                                customClass: 'custom-message-box',
                                callback: action => {}
                            })
                        }
                    })
            }).catch((err) => {
                console.log(err)
            })
        }
        // 同步订单
        syncOrder (row) {
            this.$http.get(`paying/xingyeapi/searchOrder/${row.drawerId}?orderId=${row.id}`)
                .then((res) => {
                    if (res.status == 200){
                        this.getOrderList();
                        this.getAllTips()
                        this.getOrderTips()
                        this.$alert('订单同步成功。','提示',{
                            confirmButtonText: '确定',
                            customClass: 'custom-message-box',
                            callback: action => {}
                        })
                    }
                })
        }
        // 签收订单
        signInfor (row) {
            this.$confirm('确认签收吗？','提醒',{
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                customClass: 'custom-message-box',
                center: true
            }).then(() => {
                this.$http.put(`paying/xingyeapi/pay/orderId=${row.id}`)
                    .then((res) => {
                        if(res.status == 200){
                            this.getOrderList();
                            this.getAllTips();
                            this.getOrderTips()
                            this.$alert('订单签收成功。','提示',{
                                confirmButtonText: '确定',
                                customClass: 'custom-message-box',
                                callback: action => {}
                            })
                        }
                    })
            }).catch((err) => {
                console.log(err)
            })
        }
        // 重发(重新签收)
        sendAgain (row) {
            this.$confirm('确认重新签收吗？','提醒',{
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                customClass: 'custom-message-box',
                center: true
            }).then(() => {
                this.$http.post(`paying/xingyeapi/payAgain/orderId=${row.id}`)
                    .then((res) => {
                        if(res.status == 200){
                            this.getOrderList();
                            this.getAllTips()
                            this.getOrderTips()
                            this.$alert('订单重发成功。','提示',{
                                confirmButtonText: '确定',
                                customClass: 'custom-message-box',
                                callback: action => {}
                            })
                        }
                    })
            }).catch((err) => {
                console.log(err)
            })
        }
        // 查看评价信息
        openEvaluate (row) {
            this.$http.get(`order/appraisal/${row.id}`)
                .then((res) => {
                    if (res.status == 200) {
                        this.evaluateModel = res.data;
                        this.evaluateModel.order_status_id = row.orderStatusId;
                        this.$refs['evaluateDetail'].openDialog();
                    }
                })
        }

        // 修改票据，并审核成功
        async checkBillPost (form) {
            let res = await this.$http.post('bills/billCheck',form)
            if(res.status == 200){
                this.$alert('修改成功','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
        }
        // 确认修改票据信息
        confirmSave () {
            this.billForm.bill_deadline_time = moment(this.billForm.bill_deadline_time).format('YYYY-MM-DD')
            if(!this.billForm.bill_number || this.billForm.bill_number.length != 30){
                this.$alert('请输入正确票据号！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            if(!this.billForm.bill_sum_price){
                this.$alert('请输入票面金额！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            if(!this.billForm.acceptor_cnaps){
                this.$alert('请输入承兑行号！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            if(!this.billForm.acceptor_name){
                this.$alert('请输入承兑人！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            if(!this.billForm.bill_deadline_time || this.billForm.bill_deadline_time == null){
                this.$alert('请选择票据到期日！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            if(!this.billForm.acceptor_type_id){
                this.$alert('请选择承兑机构！','提示',{
                    confirmButtonText: '确定',
                    customClass: 'custom-message-box',
                    callback: action => {}
                })
            }
            let checkForm = {
                is_real: 1,
                ...this.billForm
            }
            this.$confirm('确认修改吗？','提醒',{
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                customClass: 'custom-message-box',
                center: true
            }).then(() => {
                this.checkBillPost(checkForm);
            }).catch((err) => {
                console.log(err)
            })
        }
        loadDataForPagination() {
            this.getOrderList()
        }
        mounted () {
            let orderManageActive = localStorage.getItem('orderManageActive')
            if (orderManageActive == undefined || orderManageActive == 'undefined' || orderManageActive == null || orderManageActive == 'null') {
                this.activeName = this.activeName
            }else {
                this.activeName = orderManageActive
            }
            if (this.activeName == 'confirming') {
                this.getOrderList();
            }else {
                this.handleClick(this.activeName);
            }
            this.getOrderTips()
        }
    }
</script>
<style lang="scss" scoped>
    .clear_filter_btn {
        position: absolute;
        right: 10px;
        bottom: 4px;
        .el-button {
            padding: 0;
        }
    }
    .filter_box {
        border-radius: 4px;
        padding-top: 16px;
        border: 1px solid $__color-border;
        .el-form-item {
            margin-bottom: 8px;
        }
    }
    .filter_box_con {
        position: relative;
        padding-bottom: 12px;
    }
    .bid_status_box {
        position: relative;
    }
    .bid_list_box {
        position: absolute;
        width: 440px;
        height: 280px;
        border: 1px solid #ddd;
        top: 75px;
        left: -220px;
        z-index: 999;
        background: #fff;
    }
    .bid_list_title {
        height: 50px;
        line-height: 50px;
        color: #999;
        font-size: $__font-size-default;
        padding-left: 18px;
        border-bottom: 1px solid #ddd;
    }
    .evaluate_title {
        margin-left: 80px;
    }
    .evaluate_con_div {
        height: 30px;
        line-height: 30px;
    }
    .evaluate_con_left {
        margin-left: 16px;
    }
    .evaluate_con_main {
        color: $__color-pc-primary;
        font-size: $__font-size-default;
        @extend .evaluate_con_left;
    }
</style>
<style lang="scss">
    .tab_check_bill {
        .el-tabs__nav.is-stretch {
            min-width: 15%;
        }
    }

    .bill_img_box {
        width: 940px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        margin-bottom: 20px;
        .bill_detail_img {
            width: 240px;
            height: 148px;
            border: 1px dashed $__color-border;
            padding: 8px 10px;
            margin-bottom: 8px;
            /*img {*/
                /*max-width: 207px;*/
                /*max-height: 148px;*/
            /*}*/
        }
    }
    .text_left {
        text-align: left !important;
    }
    .order-form-box {
        .el-form-item {
            margin-bottom: 0;
        }
    }
    .terminate_reason {
        .el-textarea__inner {
            width: 534px;
            height: 90px;
        }
        margin-top: 20px;
    }

    .transaction-progess {
        width: 116px;
        .el-step__main{
            display: flex;
        }
    }
    .transaction-progess {
        .el-step__icon-inner {
            display: none;
        }
        .el-step__icon {
            width: 8px;
            height: 8px;
        }
        .el-step.is-vertical .el-step__line {
            left: 3px;
            top: 8px;
            height: 58px;
        }
    }
    .transaction-progess-box {
        display: flex;

        padding: 0px 20px;
        .el-step.is-vertical .el-step__head {
            width: 9px;
        }
    }
    .transaction-remind {
        width: 400px;
        height: 160px;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 30px 25px;
        margin-top: 20px;
    }
    .bid_table.el-table  {
        thead {
            color: #999;
            font-size: $__font-size-default;
            th {
                text-align: center;
            }
            .cell {
                font-weight: 500;
            }
        }
    }
    .bid_table {
        tbody {
            .el-table__row {
                td {
                    text-align: center;
                }
            }
        }
    }
</style>